if(WIN32)
    add_definitions("-DLUA_BUILD_AS_DLL")
    add_definitions( -D_CRT_SECURE_NO_WARNINGS )
endif(WIN32)

add_definitions(-DLUA_USE_DLOPEN)

aux_source_directory(. LUA_SOURCES)
list(REMOVE_ITEM LUA_SOURCES "./lua.c" "./luac.c")

message(${LUA_SOURCES})

set(LUA_LIBRARY lualib)
add_library(${LUA_LIBRARY} SHARED ${LUA_SOURCES})

add_executable(mylua lua.c)
target_link_libraries(mylua ${LUA_LIBRARY} m dl)

add_executable(myluac ${LUA_SOURCES} luac.c)
target_link_libraries(myluac m dl)




